/*-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License.You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
	
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.
	
The Original Code is Fever RS ( ActionScript 3 ) Framework code.
	
The Initial Developer of the Original Code is Romain Ecarnot.
Portions created by Initial Developer are Copyright (C) 2006
the Initial Developer. All Rights Reserved.
	
Contributor(s):
	
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-----------------------------------------------------------------------------*/

package fever.plugin.manager.events 
{
	import com.bourre.events.BasicEvent;
	import com.bourre.events.EventChannel;
	
	import fever.plugin.manager.RegistredPluginInfo;	

	/**
	 * Plugin event structure used in Plugin Manager API.
	 * 
	 * <p>Communication throw registred and manager plugins is done 
	 * using Event API and <strong>PluginManagerEvent</strong> event type.
	 * 
	 * @author Romain Ecarnot
	 */
	public class PluginManagerEvent extends BasicEvent
	{
		//--------------------------------------------------------------------
		// Events
		//--------------------------------------------------------------------
		
		/**
		 * Defines the value of the <code>type</code> property of the event 
		 * object for a <code>onActivatePlugin</code> event.
		 * 
		 * <p>The properties of the event object have the following values:</p>
	     *  <table class="innertable">
	     *     <tr><th>Property</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>target</code></td>
	     *     	<td>The Object that defines the event listener that handles the event</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>type</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     
	     *     <tr><th>Method</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>getTarget()</code>
	     *     	</td><td>The Object that defines the
	     *       event listener that handles the event</td></tr>
	     *     <tr>
	     *     	<td><code>getType()</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>getPluginChannel()</code></td>
	     *     	<td>Targeted plugin channel</td>
	     *     </tr>
	     *  </table>
	     * 
		 * @eventType onActivatePlugin
		 */
		public static const onActivatePluginEVENT : String = "onActivatePlugin";

		/**
		 * Defines the value of the <code>type</code> property of the event 
		 * object for a <code>onDesactivatePlugin</code> event.
		 * 
		 * <p>The properties of the event object have the following values:</p>
	     *  <table class="innertable">
	     *     <tr><th>Property</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>target</code></td>
	     *     	<td>The Object that defines the event listener that handles the event</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>type</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     
	     *     <tr><th>Method</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>getTarget()</code>
	     *     	</td><td>The Object that defines the
	     *       event listener that handles the event</td></tr>
	     *     <tr>
	     *     	<td><code>getType()</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>getPluginChannel()</code></td>
	     *     	<td>Targeted plugin channel</td>
	     *     </tr>
	     *  </table>
	     * 
		 * @eventType onDesactivatePlugin
		 */
		public static const onDesactivatePluginEVENT : String = "onDesactivatePlugin";

		/**
		 * Defines the value of the <code>type</code> property of the event 
		 * object for a <code>onRegisterPlugin</code> event.
		 * 
		 * <p>The properties of the event object have the following values:</p>
	     *  <table class="innertable">
	     *     <tr><th>Property</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>target</code></td>
	     *     	<td>The Object that defines the event listener that handles the event</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>type</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     
	     *     <tr><th>Method</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>getTarget()</code>
	     *     	</td><td>The Object that defines the
	     *       event listener that handles the event</td></tr>
	     *     <tr>
	     *     	<td><code>getType()</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>getPluginChannel()</code></td>
	     *     	<td>Targeted plugin channel</td>
	     *     </tr>
	     *  </table>
	     * 
		 * @eventType onRegisterPlugin
		 */
		public static const onRegisterPluginEVENT : String = "onRegisterPlugin";

		/**
		 * Defines the value of the <code>type</code> property of the event 
		 * object for a <code>onUnregisterPlugin</code> event.
		 * 
		 * <p>The properties of the event object have the following values:</p>
	     *  <table class="innertable">
	     *     <tr><th>Property</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>target</code></td>
	     *     	<td>The Object that defines the event listener that handles the event</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>type</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>channel</code></td>
	     *     	<td>Plugin channel to register</td>
	     *     </tr>
	     *     <tr>
	     *     	<td><code>data</code></td>
	     *     	<td>Plugin data to register</td>
	     *     </tr>
	     *     
	     *     <tr><th>Method</th><th>Value</th></tr>
	     *     <tr>
	     *     	<td><code>getTarget()</code>
	     *     	</td><td>The Object that defines the
	     *       event listener that handles the event</td></tr>
	     *     <tr>
	     *     	<td><code>getType()</code></td>
	     *     	<td>Dispatched event type</td>
	     *     </tr>
	     *  </table>
	     * 
		 * @eventType onUnregisterPlugin
		 */
		public static const onUnregisterPluginEVENT : String = "onUnregisterPlugin";
				
		//--------------------------------------------------------------------
		// Private properties
		//--------------------------------------------------------------------
		
		private var _channel : EventChannel;		private var _data : RegistredPluginInfo;
		
		
		//--------------------------------------------------------------------
		// Public properties
		//--------------------------------------------------------------------
		
		/**
		 * Plugin channel to register
		 */
		public function get channel() : EventChannel { return _channel; }
		
		/**
		 * Plugin data to register
		 */		public function get data() : RegistredPluginInfo { return _data; }
		

		//--------------------------------------------------------------------
		// Public API
		//--------------------------------------------------------------------
		
		/**
		 * Constructor.
		 * 
		 *  @param pType Event type to dispatch
		 *  @param pluginChannel Plugin channel to register
		 */
		public function PluginManagerEvent( pType : String, 
			pluginChannel : EventChannel, 
			pluginData : RegistredPluginInfo = null )
		{
			super( pType );
			
			_channel = pluginChannel;			_data = pluginData;
		}	
	}
}
